package org.jivesoftware.smack.packet;

import org.jivesoftware.smack.util.StringUtils;

public class Authentication extends IQ
{
  private String digest;
  private String password;
  private String resource;
  private String username = null;

  public Authentication()
  {
    this.password = null;
    this.digest = null;
    this.resource = null;
    setType(IQ.Type.SET);
  }

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<query xmlns=\"jabber:iq:auth\">");
    if (this.username != null)
    {
      if (!(this.username.equals("")))
        break label138;
      localStringBuilder.append("<username/>");
    }
    if (this.digest != null)
    {
      if (!(this.digest.equals("")))
        break label160;
      localStringBuilder.append("<digest/>");
    }
    if ((this.password != null) && (this.digest == null))
    {
      if (!(this.password.equals("")))
        break label182;
      localStringBuilder.append("<password/>");
    }
    if (this.resource != null)
    {
      if (!(this.resource.equals("")))
        break label207;
      localStringBuilder.append("<resource/>");
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            localStringBuilder.append("</query>");
            return localStringBuilder.toString();
            label138: localStringBuilder.append("<username>").append(this.username).append("</username>");
          }
          label160: localStringBuilder.append("<digest>").append(this.digest).append("</digest>");
        }
        label182: localStringBuilder.append("<password>").append(StringUtils.escapeForXML(this.password)).append("</password>");
      }
      label207: localStringBuilder.append("<resource>").append(this.resource).append("</resource>");
    }
  }

  public String getDigest()
  {
    return this.digest;
  }

  public String getPassword()
  {
    return this.password;
  }

  public String getResource()
  {
    return this.resource;
  }

  public String getUsername()
  {
    return this.username;
  }

  public void setDigest(String paramString)
  {
    this.digest = paramString;
  }

  public void setDigest(String paramString1, String paramString2)
  {
    this.digest = StringUtils.hash(paramString1 + paramString2);
  }

  public void setPassword(String paramString)
  {
    this.password = paramString;
  }

  public void setResource(String paramString)
  {
    this.resource = paramString;
  }

  public void setUsername(String paramString)
  {
    this.username = paramString;
  }
}